package de.fhluebeck.oop.gps.cmd;

import de.fhluebeck.oop.gps.common.Constants;
import de.fhluebeck.oop.gps.common.DependencyManager;
import de.fhluebeck.oop.gps.service.ICategoryService;
import de.fhluebeck.oop.gps.service.IDatabaseService;
import de.fhluebeck.oop.gps.service.IPoiService;

/**
 *
 * Commandline Option zur Erstellung von DummyDaten in der Datenbank
 * Die Datenbank wird vor Erstellung von DummyDatensätzen geleert
 * 
 * @author Ogün Bilge, Leif Hitzschke
 * @version 1.00, 13.11.2009
 * 
 */

public class CreateDummyDataOption extends Option {

	private final static String KEY = "-createdummy";
	private Option successor;
	
	public CreateDummyDataOption(Option successor) {
		this.successor = successor;
	}
	
	@Override
	void execute(String value) {
		
		((IDatabaseService) DependencyManager
				.locate(Constants.DATABASE_SERVICE_DEP_NAME)).initDatabase();
		
		// init dummy categories
		((ICategoryService) DependencyManager
				.locate(Constants.CATEGORY_SERVICE_DEP_NAME))
				.createDummyCategories();

		// init dummy pois
		((IPoiService) DependencyManager.locate(Constants.POI_SERVICE_DEP_NAME))
				.createDummyPois();
	}

	@Override
	Option getSuccessor() {
		return successor;
	}

	@Override
	boolean isApplicable(String key) {
		return KEY.equals(key);
	}
}
